package com.henushang.picture_pedia.picture_utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.apache.log4j.Logger;

import com.henushang.utils.Base64Util;

public class ImageUtil {
    
    private static Logger logger = Logger.getLogger(ImageUtil.class);
    
    public static String readImageFromLocal(String path) {
        String encodeImage = "";
        try {
            @SuppressWarnings("resource")
            InputStream iStream = new FileInputStream(new File(path));
            byte[] buffer = new byte[iStream.available()];
            iStream.read(buffer);
            encodeImage = Base64Util.encode(buffer);
        } catch(Exception e) {
            logger.error("read image from local error! path:" + path, e);
        }
        return encodeImage;
    }
    
}
